home *** CD-ROM | disk | FTP | other *** search
- /*
- File: USBEnetDriver.h
-
- Contains: xxx put contents here xxx
-
- Version: xxx put version here xxx
-
- Copyright: © 2000 by Apple Computer, Inc., all rights reserved.
-
- File Ownership:
-
- DRI: xxx put dri here xxx
-
- Other Contact: xxx put other contact here xxx
-
- Technology: xxx put technology here xxx
-
- */
-
- #ifndef _USBENETDRIVER_
- #define _USBENETDRIVER_
-
- typedef struct
- {
- UInt8 bFunctionLength;
- UInt8 bDescriptorType;
- UInt8 bDescriptorSubtype;
- UInt8 iMACAddress;
- UInt8 bmEthernetStatistics[4];
- UInt8 wMaxSegmentSize[2];
- UInt8 wNumberMCFilters[2];
- UInt8 bNumberPowerFilters;
- } FunctionalDescriptor;
-
- typedef struct
- {
- USBPB pb;
- unsigned char *errorString;
- UInt16 interfacenum;
- USBDeviceRef deviceRef;
- USBInterfaceRef interfaceRef;
- USBPipeRef interrupt;
- USBPipeRef bulkIn;
- USBPipeRef bulkOut;
- USBDeviceDescriptorPtr deviceDescriptor;
- FunctionalDescriptor FuncDesc;
- UInt8 bMACAddress[6];
- UInt8 onError;
- UInt8 retries;
- } EnetPB;
-
- typedef UInt8 EnetAddress[6];
- typedef UInt8 *EnetAddressPtr;
-
- typedef struct EnetAddressListElement EnetAddressListElement;
- typedef EnetAddressListElement *EnetAddressListPtr;
-
- struct EnetAddressListElement
- {
- EnetAddressListPtr next;
- EnetAddress address;
- UInt8 _pad[2];
- };
-
- enum{
- kReset = 0,
- kCommConfig = 1,
- kSetConfig = 2,
- kGetCommInterface = 3,
- kSetCommInterface = 4,
- kConfigureCommInterface = 5,
- kGetInterruptEndpoint = 6,
- kStartGetDescriptors = 7,
- kGetDescriptors = 8,
- kSetDataConfig = 9,
- kDataConfig = 10,
- kGetDataInterface = 11,
- kConfigureDataInterface = 12,
- kGetBulkOutEndpoint = 13,
- kGetBulkInEndpoint = 14,
- kConfigDone = 15,
- kInstallDrvr = 16,
-
- kEndpointStall = 1,
- kStallDone = 2,
- kAvailableStatus = 'okok'
- };
-
- // Requests
- enum{
- kSend_Encapsulated_Command = 0,
- kGet_Encapsulated_Response = 1,
- kSet_Ethernet_Multicast_Filter = 0x40,
- kSet_Ethernet_Power_Management_Packet_Filter = 0x41,
- kGet_Ethernet_Power_Management_Packet_Filter = 0x42,
- kSet_Ethernet_Packet_Filter = 0x43,
- kGet_Ethernet_Statistics = 0x44,
- kGet_AUX_Inputs = 4,
- kSet_AUX_Outputs = 5,
- kSet_Temp_MAC = 6,
- kGet_Temp_MAC = 7,
- kSet_URB_Size = 8,
- kSet_SOFS_To_Wait = 9,
- kSet_Even_Packets = 10,
- kScan = 0xFF
- };
-
- //Notifications
- enum{
- kNetwork_Connection = 0,
- kResponse_Available = 1,
- kConnection_Speed_Change = 0x2A
- };
-
- enum{
- kInterrupt = 100,
- kReplaceInterrupt = 2,
- kFixupInterrupt = 3,
- kForceInterrupt = 6,
-
- kURB_Size = 4096,
- kSOFS = 1,
- kType_Multicast = 0x0010,
- kType_Broadcast = 0x0008,
- kType_Directed = 0x0004,
- kType_All_Multicast = 0x0002,
- kType_Promiscuous = 0x0001
- };
-
- enum{
- CS_Interface = 0x24,
- Ethernet_Functional_Descriptor = 0x0f
- };
-
- /********************************************************************************************/
- //
- // Prototypes
- //
- /********************************************************************************************/
-
- void CheckUSBVersion(void);
- void USBStatus(UInt32 level, USBDeviceRef ref, void *pointer, UInt32 value);
- static Boolean immediateError(OSStatus err);
- static void ConfigurationHandler(USBPB *pb);
- static void ResetInterruptPB(USBPB *pb);
- static void interruptCompletion(USBPB *pb);
- static void StartStatusMonitor(USBPipeRef interruptPipe);
- static void syncCompletion(USBPB *pb);
- UInt32 USBReadData(UInt8 *buf, UInt32 size);
- void USBGetAddress(UInt32 *count, UInt8 *buf);
- void USBSetisr(ProcPtr isr, void *cookie);
- OSStatus USBSetAddress(UInt32 count, UInt8 *buf);
- OSStatus USBSetMulticastFilters(UInt32 numFilters, EnetAddressListPtr list);
- OSStatus USBSetPacketFilter(UInt16 *filter);
- Boolean TimeoutPrevRequest(void);
- Boolean TimeoutStallRequest(void);
- Boolean TimeoutDelayRequest(void);
- OSStatus USBEnetDriverEntry(USBDeviceRef device, USBDeviceDescriptor *desc);
- static void InitializePB(USBPB *pb, USBDeviceRef ref, USBCompletion handler);
- void readCompletion(USBPB *pb);
- void USBStartupRead(void);
- void USBStartReadPolling(UInt32 bufindx);
- void USBStopReadPolling(void);
- void writeCompletion(USBPB *pb);
- OSStatus USBEnetWrite(UInt32 count, UInt8 *buf);
- void KillUSBIO(void);
- void DoDelay(void);
- static void delayHandler(USBPB *pb);
- void ClearDevice(void);
- static void stallHandler(USBPB *pb);
- UInt8 Asciify(UInt8 i);
-
- #if ((DebugOn > 0) && (LogOn > 0))
- void USBLogData(UInt8 Dir, UInt32 Count, UInt8 *buf);
- #endif
-
- #endif
-